package com.me.shardingdemo.web.api;

import com.me.shardingdemo.web.model.Position;
import com.me.shardingdemo.web.service.IPositionService;
import lombok.AllArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

@RestController
@AllArgsConstructor
@RequestMapping("position")
public class PositionController {

    private final IPositionService positionServiceImpl;

    @GetMapping("get")
    public ResponseEntity<Position> getById(@RequestParam("id") Long id) {
        return ResponseEntity.ok(positionServiceImpl.getById(id));
    }

    @PostMapping("add")
    public ResponseEntity<Boolean> add(@RequestBody Position position) {
        return ResponseEntity.ok(positionServiceImpl.saveOrUpdate(position));
    }
}
